<?php require admin_tpl('header');?>

<div class="tab">
	<ul>
		<li><a href="#" class="on">在线更新</a></li>
	</ul>
</div>
<div class="main">

	<form name="op" method="post" action="?mod=tag">
	<input type="hidden" name="dosubmit" value="yes" />
		<table class="datalist" cellspacing="0" id="list">
			<tr>
				<th width="50">ID</th>
				<th width="400">文件</th>
				<th width="150">状态</th>
				<th>&nbsp;</th>
			</tr>
			<?php
			foreach ( $filelist as $key => $file ) {
			?>
			<tr id="file_<?php echo $key?>">
				<td align="center"><?php echo $key; ?></td>
				<td><a href="<?php echo $file['url']; ?>" onclick="alert('请点击鼠标右键,选择[目标另存为]');return false;"><?php echo $file['file']; ?></a></td>
				<td align="center" id="status_<?php echo $key;?>">&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<?php
			}	
			?>
			<tr>
				<td colspan="5"><input type="button" class="button" onclick="start_down(0)" value="下载并应用" /></td>
			</tr>
		</table>
	</form>
</div>
<script type="text/javascript">
	function start_down(id) {
		$('#status_'+id).html('下载中...');
		$.get('admin.php','mod=update&ac=downfile&id='+id+'&t='+Math.random(), function(msg) {
			if ( msg == 'done' ) {
				return;
			} else if ( msg == 'ok' ) {
				$('#status_'+id).html('<span style="color:green">下载成功!</span>');
				start_down(++id);
			} else if ( msg == 'failed' ) {
				$('#status_'+id).html('<span style="color:red">下载失败!</span> <a href="javascript:;" onclick="start_down('+id+')">重试</a>');
				return;
			}
		});
	}
</script>
<?php require admin_tpl('footer');?>